import request from '@/utils/request.js'
export const login = function (data) {
  return request.post('/user/login', data)
}
export const register = function (data) {
  return request.post('/user/registered', data)
}
export const swiper = function () {
  return request.get('/home/swiper')
}
export const group = function () {
  return request.get('/home/groups')
}
export const houseList = function (cityId) {
  return request.get('/houses', { params: { cityId } })
}
export const areaList = function (level) {
  return request.get('/area/city', { params: { level } })
}
export const cityHot = function () {
  return request.get('/area/hot')
}

// 获取房屋列表
export const housesListGet = function (params) {
  return request.get('/houses', { params })
}

// 获取房屋查询条件
export const housesSearchGet = function (id) {
  return request.get('/houses/condition/', {
    params: {
      id
    }
  })
}

// 房屋详情
export const housesDetail = function (id) {
  return request.get('/houses/' + id)
}

// 收藏的获取，添加，删除
export const addHomeLike = function (id) {
  return request.post('/user/favorites/' + id)
}
export const subHomeLike = function (id) {
  return request.delete('/user/favorites/' + id)
}
export const getHomeLike = function (id) {
  return request.get('/user/favorites/' + id)
}
export const getHome = function (id) {
  return request.get('/houses/' + id)
}
// 添加收藏
export const addCollect = function (id) {
  return request.post('/user/favorites/' + id)
}
// 删除收藏
export const delCollect = function (id) {
  return request.delete('/user/favorites/' + id)
}
// 发布房屋所需条件
export const getHousesParams = () => {
  return request.get('/houses/params')
}
// 发布房源
export const uploadHouses = body => {
  return request.post('/user/houses', body)
}
// 房屋图像上传
export const uploadImages = form => {
  return request.post('/houses/image', form, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}
// 小区关键词查询
export const getCommunity = (name, id) => {
  return request.get('/area/community', { params: { name, id } })
}
// 根据城市名称查询该城市信息
export const getCityName = (name) => {
  return request.get('/area/info', { params: { name } })
}
